# -*- coding: utf-8 -*-
"""
Created on Tue Apr 16 13:48:12 2024

@author: 29865
"""

import pandas as pd

# 创建一个简单的 Series
s = pd.Series([1, 2, 3, 4, 5])

# 计算3个数据点的滚动均值
rolling_mean = s.rolling(window=3).mean()
# 计算3个数据点的滚动求和
rolling_sum = s.rolling(window=3).sum()
# 计算3个数据点的滚动标准差
rolling_std = s.rolling(window=3).std()


# 创建一个简单的 DataFrame
df = pd.DataFrame({
    'A': [1, 2, 3, 4, 5],
    'B': [10, 20, 30, 40, 50]
})

# 计算两列各自的3个数据点的滚动均值
df_rolling_mean = df.rolling(window=3).mean()
